package com.leetcode.LC;

import java.util.ArrayList;

public class LC1078 {
    public String[] findOcurrences(String text, String first, String second) {

        ArrayList<String> list = new ArrayList<>();
        String[] s = text.split(" ");
        for (int i = 0; i < s.length - 2; i++) {
            if (s[i].equals(first)&&s[i+1].equals(second)){
                list.add(s[i+2]);
            }
        }

        String[] strings = new String[list.size()];
        for (int i = 0; i < list.size(); i++) {
            strings[i]=list.get(i);
        }

        return strings;

    }

}
